




#include "MainFrm.h"
#include "dbPOS.h"

#include "wx/jsonval.h"
#include "wx/jsonwriter.h"
#include "wx/jsonreader.h"
#include "wx/wfstream.h"
#include "wx/filesys.h"



class MainFrm : public MyFrame1
{
public:
	MainFrm( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("wxPOS Monitor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 691,480 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
		//~MainFrm();

protected:

	void PosSelect(wxTreeEvent &event);
	void BatchRowSelect(wxGridEvent &event);
	void LableClicked(wxGridEvent &event);

	void Synch_Menu_Click(wxCommandEvent &event);
	void Synch_Tool_Click(wxCommandEvent &event);
	void Help_Tool_Click(wxCommandEvent &event);
	void Help_Menu_Click(wxCommandEvent &event);
	void Exit_Menu_Click(wxCommandEvent &event);
	void SettingToolClick(wxCommandEvent &event);
		
	bool GetData();
	bool dbConnect();

	wxVariant GetSettingValue(wxString setname)
	{
		
		wxFileSystem* fs = new wxFileSystem();
		
		wxFSFile* file = fs->OpenFile(wxT("wxConfig.cfg"));
		
		
		wxInputStream* stream = file->GetStream(); 
		wxJSONReader reader;  
		wxJSONValue  root; 
		wxVariant value;
		int numErrors = reader.Parse( *stream, &root );  
		if ( numErrors > 0 )  {  
		 const wxArrayString& errors = reader.GetErrors();  
		 wxString msg;
		 for(int i=0; i< numErrors; i++)
		 {
			msg+=errors[i]+wxT("/n");
		 }
		 wxMessageBox(msg);
		  
		 return NULL;  
		}
		
		value = root[wxT("Settings")][setname].AsString();
	
		return value;
	};
};



class SettingDlg : public MyDialog2
{
public:
	
	SettingDlg(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString &title = wxT("Settings"),const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 329,149 ), long style = wxDEFAULT_DIALOG_STYLE );

	void onDialogShow(wxInitDialogEvent& event);
	void DialogOkClick( wxCommandEvent& event);

protected:
	

};


